package com.itheima.imclient100.callback;

import com.hyphenate.EMCallBack;
import com.itheima.imclient100.utils.ThreadUtils;

/**
 * Created by fullcircle on 2017/7/2.
 */

public abstract class MyEmCallBack implements EMCallBack {
    //声明两个抽象方法 都是在主线程中调用 success 处理成功的回调
    public abstract  void success();
    //error 处理返回错误的回调
    public abstract  void error(int i, String s);
    public void progress(int i, String s){

    }

    @Override
    public void onSuccess() {
        ThreadUtils.runOnMainThread(new Runnable() {
            @Override
            public void run() {
                success();
            }
        });
    }

    @Override
    public void onError(final int i, final String s) {
        ThreadUtils.runOnMainThread(new Runnable() {
            @Override
            public void run() {
                error(i,s);
            }
        });
    }

    @Override
    public void onProgress(final int i, final String s) {
        ThreadUtils.runOnMainThread(new Runnable() {
            @Override
            public void run() {
                progress(i,s);
            }
        });
    }
}
